/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Mansur
 */
@Entity
@Table(name = "ship_visit3_sub_ext")
@NamedQueries({
    @NamedQuery(name = "ShipVisit3SubExtend.findAll", query = "SELECT s FROM ShipVisit3SubExtend s")})
public class ShipVisit3SubExtend implements Serializable{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ship_visit3se_id")
    private Integer shipVisit3SubExtId;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ship_visit3s_id")
    private ShipVisit3Sub shipVisit3Sub;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ref_ss_id")
    private RefShipVisitSub shipVisitSub;
    
    @Column(name = "details")
    private String details;
    
    @Column(name = "input_type")
    private String inputType;  // S=Single Line, M=Multiple Line
    
    @Embedded
    private InfoAudit infoAudit;
    
    @OneToMany (mappedBy = "shipVisit3SubExtend" , fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<ShipVisit3SubExtendFile> listFile;
    
    public ShipVisit3SubExtend(){
        
    }

    public Integer getShipVisit3SubExtId() {
        return shipVisit3SubExtId;
    }

    public void setShipVisit3SubExtId(Integer shipVisit3SubExtId) {
        this.shipVisit3SubExtId = shipVisit3SubExtId;
    }

    public ShipVisit3Sub getShipVisit3Sub() {
        return shipVisit3Sub;
    }

    public void setShipVisit3Sub(ShipVisit3Sub shipVisit3Sub) {
        this.shipVisit3Sub = shipVisit3Sub;
    }

    public RefShipVisitSub getShipVisitSub() {
        return shipVisitSub;
    }

    public void setShipVisitSub(RefShipVisitSub shipVisitSub) {
        this.shipVisitSub = shipVisitSub;
    }

    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    public String getInputType() {
        return inputType;
    }

    public void setInputType(String inputType) {
        this.inputType = inputType;
    }

    public InfoAudit getInfoAudit() {
        return infoAudit;
    }

    public void setInfoAudit(InfoAudit infoAudit) {
        this.infoAudit = infoAudit;
    }

    public List<ShipVisit3SubExtendFile> getListFile() {
        List<ShipVisit3SubExtendFile> l = new ArrayList<ShipVisit3SubExtendFile>();
        for (ShipVisit3SubExtendFile f : listFile) {
            if(f.getDeleted().equals("N"))
                l.add(f);
        }
        listFile.clear();
        listFile = l;
        return listFile;
    }

    public void setListFile(List<ShipVisit3SubExtendFile> listFile) {
        this.listFile = listFile;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (shipVisit3SubExtId != null ? shipVisit3SubExtId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ShipVisit3SubExtend)) {
            return false;
        }
        ShipVisit3SubExtend other = (ShipVisit3SubExtend) object;
        if ((this.shipVisit3SubExtId == null && other.shipVisit3SubExtId != null) || (this.shipVisit3SubExtId != null && !this.shipVisit3SubExtId.equals(other.shipVisit3SubExtId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "exatrez.model.ShipVisit3SubExtend[ shipVisit3SubExtId=" + shipVisit3SubExtId + " ]";
    }
}
